VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmMain 
   BackColor       =   &H001D1D1D&
   Caption         =   "BNET.cc Bot "
   ClientHeight    =   5625
   ClientLeft      =   255
   ClientTop       =   1005
   ClientWidth     =   11115
   FillColor       =   &H0080FFFF&
   FillStyle       =   3  'Vertical Line
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   9
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   ForeColor       =   &H00008000&
   Icon            =   "frmMain.frx":0000
   LinkTopic       =   "None"
   PaletteMode     =   2  'Custom
   Picture         =   "frmMain.frx":164A
   ScaleHeight     =   5625
   ScaleWidth      =   11115
   Begin VB.Timer tmrConnect 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   5760
      Top             =   240
   End
   Begin VB.Timer ConnectTimer 
      Enabled         =   0   'False
      Interval        =   1
      Left            =   5280
      Top             =   240
   End
   Begin VB.Timer IdleTimer 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   4800
      Top             =   240
   End
   Begin VB.Timer tmrDC 
      Enabled         =   0   'False
      Interval        =   60000
      Left            =   4320
      Top             =   240
   End
   Begin VB.Timer tmrUptime 
      Interval        =   1000
      Left            =   3840
      Top             =   240
   End
   Begin VB.Timer tmrAntiIdle 
      Enabled         =   0   'False
      Interval        =   1000
      Left            =   3360
      Top             =   240
   End
   Begin MSComctlLib.ListView lstChannel 
      Height          =   4200
      Left            =   8520
      TabIndex        =   1
      Top             =   360
      Width           =   3255
      _ExtentX        =   5741
      _ExtentY        =   7408
      View            =   3
      Arrange         =   1
      LabelEdit       =   1
      MultiSelect     =   -1  'True
      LabelWrap       =   0   'False
      HideSelection   =   -1  'True
      HideColumnHeaders=   -1  'True
      AllowReorder    =   -1  'True
      FullRowSelect   =   -1  'True
      PictureAlignment=   3
      _Version        =   393217
      Icons           =   "ClientIcons"
      SmallIcons      =   "ClientIcons"
      ForeColor       =   16777215
      BackColor       =   1907997
      Appearance      =   0
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   2
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "a"
         Object.Width           =   4235
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "s"
         Object.Width           =   1059
      EndProperty
   End
   Begin VB.TextBox txtsendbnet 
      BackColor       =   &H00404040&
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00E0E0E0&
      Height          =   330
      Left            =   120
      MaxLength       =   225
      TabIndex        =   2
      Top             =   4560
      Width           =   7935
   End
   Begin MSWinsockLib.Winsock wsBnls 
      Left            =   1440
      Top             =   240
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin MSWinsockLib.Winsock wsBnet 
      Left            =   960
      Top             =   240
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
   End
   Begin MSComctlLib.ImageList ClientIcons 
      Left            =   9960
      Top             =   5040
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   1907997
      ImageWidth      =   28
      ImageHeight     =   14
      MaskColor       =   1907997
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   22
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":2931
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":2E1D
            Key             =   ""
            Object.Tag             =   "mod"
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":2FD0
            Key             =   ""
            Object.Tag             =   "drtl"
         EndProperty
         BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":34BC
            Key             =   ""
            Object.Tag             =   "d2dv"
         EndProperty
         BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":39A8
            Key             =   ""
            Object.Tag             =   "star"
         EndProperty
         BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":3E94
            Key             =   ""
            Object.Tag             =   "sshr"
         EndProperty
         BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":4380
            Key             =   ""
            Object.Tag             =   "stsp"
         EndProperty
         BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":486C
            Key             =   ""
            Object.Tag             =   "sexp"
         EndProperty
         BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":4D58
            Key             =   ""
            Object.Tag             =   "w2bn"
         EndProperty
         BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":5244
            Key             =   ""
            Object.Tag             =   "jstr"
         EndProperty
         BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":5730
            Key             =   ""
            Object.Tag             =   "d2xp"
         EndProperty
         BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":5D28
            Key             =   ""
            Object.Tag             =   "sqeulch"
         EndProperty
         BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":5F05
            Key             =   ""
            Object.Tag             =   "bot"
         EndProperty
         BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":63F1
            Key             =   ""
            Object.Tag             =   "jssr"
         EndProperty
         BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":68DD
            Key             =   ""
         EndProperty
         BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":6B95
            Key             =   ""
         EndProperty
         BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":71FD
            Key             =   ""
         EndProperty
         BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":7817
            Key             =   ""
         EndProperty
         BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":7C40
            Key             =   ""
         EndProperty
         BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":8138
            Key             =   ""
         EndProperty
         BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":87C8
            Key             =   ""
         EndProperty
         BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmMain.frx":89CE
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin InetCtlsObjects.Inet devNEWS 
      Left            =   240
      Top             =   240
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      Protocol        =   4
   End
   Begin RichTextLib.RichTextBox rtbChat 
      Height          =   4335
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   7935
      _ExtentX        =   13996
      _ExtentY        =   7646
      _Version        =   393217
      BackColor       =   2368548
      Enabled         =   -1  'True
      ReadOnly        =   -1  'True
      ScrollBars      =   2
      DisableNoScroll =   -1  'True
      AutoVerbMenu    =   -1  'True
      TextRTF         =   $"frmMain.frx":8FE8
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "Verdana"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
   End
   Begin VB.Label txtChannelInfo 
      Alignment       =   2  'Center
      BackColor       =   &H00000000&
      BackStyle       =   0  'Transparent
      Caption         =   "www.BNET.cc"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C0C000&
      Height          =   255
      Left            =   8520
      TabIndex        =   3
      Top             =   120
      Width           =   3135
   End
   Begin VB.Menu mnuMail 
      Caption         =   "&Bot"
      Begin VB.Menu mnuConnect 
         Caption         =   "Connect to Battle.net.."
      End
      Begin VB.Menu mnuDisconnect 
         Caption         =   "Disconnect from Battle.net"
      End
      Begin VB.Menu Reconnect 
         Caption         =   "Reconnect to Battle.net..."
      End
      Begin VB.Menu sep123 
         Caption         =   "-"
      End
      Begin VB.Menu mnuExit 
         Caption         =   "Exit"
      End
   End
   Begin VB.Menu mnuConfigure 
      Caption         =   "&Configure"
      Begin VB.Menu mnuSetupOption 
         Caption         =   "Edit Configuration"
         Shortcut        =   {F6}
      End
      Begin VB.Menu AA 
         Caption         =   "-"
      End
      Begin VB.Menu ToTray 
         Caption         =   "Minimize to System Tray"
         Shortcut        =   ^S
      End
      Begin VB.Menu mnuClearBufs 
         Caption         =   "Clear Chat Buffers"
         Shortcut        =   %{BKSP}
      End
   End
   Begin VB.Menu mnuOther 
      Caption         =   "&Other"
      Begin VB.Menu mnuAbout 
         Caption         =   "About.."
      End
      Begin VB.Menu mnuUpdate 
         Caption         =   "Update"
         Shortcut        =   ^U
      End
      Begin VB.Menu mnuWebsite 
         Caption         =   "Website"
      End
      Begin VB.Menu mnuBug 
         Caption         =   "Report Bugs"
         Shortcut        =   ^B
      End
   End
   Begin VB.Menu mnuUserList 
      Caption         =   "UserList"
      Visible         =   0   'False
      Begin VB.Menu mnuOp 
         Caption         =   "--Ops--"
         Enabled         =   0   'False
      End
      Begin VB.Menu mnuBan 
         Caption         =   "Ban"
      End
      Begin VB.Menu mnuKick 
         Caption         =   "Kick"
      End
   End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public newest As String
Public connectstatus As Boolean
Public sUserName As String
Public connectseconds As Long
Public random As Integer
Public dctime As Integer
Public privatever As Boolean
Public intRandom As Integer
Private Const WM_USER = &H400&
Private Const EM_AUTOURLDETECT = (WM_USER + 91)
Public WithEvents ChatBot As BnetBot
Attribute ChatBot.VB_VarHelpID = -1

Public Sub PrepareCheck(ByRef tocheck As String)
    tocheck = Replace(tocheck, "[", "a")
    tocheck = Replace(tocheck, "]", "x")
    tocheck = Replace(tocheck, "#", "y")
    tocheck = Replace(tocheck, "-", "z")
    tocheck = Replace(tocheck, "&", "b")
End Sub

Private Sub Command1_Click()
    ShellExecute Me.hWnd, "Open", "http://www.bnet.cc/", 0&, 0&, 0&
End Sub

Private Sub Form_Load()
    Dim InvigNews As String
    Set ChatBot = New BnetBot
    Dim lRet As Long
    frmMain.Caption = "BNET.cc Bot - http://www.BNET.cc"
    LogChat = 0
    LoadConfig
    'BNCCNews = devNEWS.OpenURL("http://www.bnet.cc/invigoration/news.txt")
    'BNCCVer = devNEWS.OpenURL("http://www.bnet.cc/invigoration/version.txt")
    'BNCCNight = devNEWS.OpenURL("http://www.bnet.cc/invigoration/nversion.txt")
    'BNCCRel = devNEWS.OpenURL("http://www.bnet.cc/invigoration/verrelease.txt")
    'AddChat D2MedBlue, "Version Check: "
    connectstatus = False
    'If InvigVer = vernum Then
    '    privatever = False
    '    AddChat D2White, "You have the latest version of Invigoration."
    '    AddChat D2Orange, "Version ", D2White, InvigVer, D2Orange, " Released on: ", D2White, InvigRel
    '    mnuUpdate.Enabled = False
    'ElseIf InvigVer < vernum Then
    '    privatever = True
        
    '    AddChat D2White, "You are running Invigoration Nightly Build...."
    '    mnuUpdate.Enabled = False
    '        Else
    '    privatever = False
    '    mnuUpdate.Enabled = True
    '    AddChat HEXPINK, "---------------------------------------------------------------------"
    ''    AddChat D2Orange, "You need to update: Hold ", vbYellow, "CTRL ", D2Orange, "and press ", vbYellow, "U", D2Orange, " to launch update file."
    ''    AddChat D2Orange, "You can also activate the Updater via the ", D2Green, "Other ", D2Orange, "menu."
    '    AddChat D2Orange, "Your version: " & vernum, D2White, "  Latest version: " & InvigVer
    '    AddChat D2Orange, "Last Update: ", D2White, X, D2Orange, " on ", D2White, R
    '    AddChat HEXPINK, "---------------------------------------------------------------------"
    '    msg = MsgBox("You need to update Invigoration. Please try using CTRL+U, if that doesn't work, close your bot and visit: http://www.clanbnu.ws/upgrade.html", vbOKOnly, "New Version Released!")
    'End If
    AddChat D2Purple, "---------------------------------------------------"
    AddChat D2MedBlue, "()()"
    AddChat D2MedBlue, "(--)"
    AddChat D2MedBlue, "(')(')"
    AddChat D2Green, "BNCC Bunny"
    AddChat D2Orange, "Public Open Source Version: " & vernum
    AddChat D2MedBlue, "---------------------------------------------------"
    frmConfigBNET.txtCDKey.text = GetStuff("BNET", "CDKey")
    random = "180"
    uptimesec = 0
    uptimemin = 0
    uptimehour = 0
    uptimedays = 0
    uptimeweek = 0
    uptimemonth = 0
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    SaveConfig
    frmMain.wsBnet.Close
    frmMain.wsBnls.Close
End
End Sub

Private Sub Form_Terminate()
    SaveConfig
    frmMain.wsBnet.Close
    frmMain.wsBnls.Close
    End
End Sub

Private Sub mnuClearBufs_Click()
    rtbChat.text = vbNullString
    AddChat D2White, "Cleared Chat Buffers. Old information is lost."
    txtsendbnet.SetFocus
End Sub
Private Sub lstChannel_Click() '(Button As Integer, Shift As Integer, X As Single, y As Single)
On Error Resume Next
If frmMain.wsBnet.State = sckConnected Then
        strList = lstChannel.SelectedItem
    txtsendbnet.SetFocus
Else
''
End If
End Sub
Private Sub lstChannel_Change() '(Button As Integer, Shift As Integer, X As Single, y As Single)
On Error Resume Next
If frmMain.wsBnet.State = sckConnected Then
        strList = lstChannel.SelectedItem
        PopupMenu mnuUserList
    txtsendbnet.SetFocus
Else
''
End If
End Sub
Private Sub mnuConnect_Click()
    With frmMain.lstChannel
        .ListItems.Clear
    End With
On Error GoTo Error
connectstatus = True
    tmrConnect.Enabled = True
    AddChat D2Green, "Battle.net Login Server Connecting to " & BNET.BNLSServer & "..."
    frmMain.wsBnls.Close
    frmMain.wsBnls.Connect BNET.BNLSServer, 9367
    frmMain.Caption = "BNET.cc Bot - [ Connecting to: " & BNET.BNLSServer & " ]"
    txtChannelInfo.Caption = "Connecting"
    txtChannelInfo.ForeColor = D2Green
    antiidlesecond = 0
    frmMain.tmrAntiIdle.Enabled = True
Error:

End Sub

Private Sub tmrConnect_Timer()
    connectseconds = connectseconds + 1
End Sub


Private Sub mnuDisconnect_Click()
    connectstatus = False
    tmrAntiIdle.Enabled = False
    frmMain.Caption = "BNET.cc Bot - www.BNET.cc"
    frmMain.wsBnet.Close
    frmMain.wsBnls.Close
    AddChat D2White, "Battle.net Closed Connection."
    lstChannel.ListItems.Clear
    frmMain.Caption = "BNET.cc Bot - [ Disconnected ]"
    txtChannelInfo.Caption = "Disconnected"
    txtChannelInfo.ForeColor = D2Red
    antiidlesecond = 0
    dctime = 0
    frmMain.tmrAntiIdle.Enabled = False
    frmMain.tmrDC.Enabled = False
    mnuConnect.Visible = True
    mnuDisconnect.Visible = False
End Sub


Private Sub mnuExit_Click()
    frmMain.wsBnet.Close
    frmMain.wsBnls.Close
    Unload Me
    End
End Sub
Private Sub mnuSetupOption_Click()
    frmConfigBNET.Show
End Sub


Private Sub Reconnect_Click()
    With frmMain.lstChannel
        .ListItems.Clear
    End With
On Error GoTo Error
    frmMain.tmrDC.Enabled = False
    frmMain.wsBnet.Close
    frmMain.wsBnls.Close
    connectstatus = False
    frmMain.Caption = "BNET.cc Bot - [ Reconnecting to: " & BNET.BNLSServer & " ]"
    AddChat D2Green, "Battle.net Login Server Reconnecting to " & BNET.BNLSServer & "..."
    frmMain.wsBnls.Close
    frmMain.wsBnls.Connect BNET.BNLSServer, 9367
    txtChannelInfo.Caption = "Reconnecting"
    txtChannelInfo.ForeColor = D2Orange
    connectstatus = True
    antiidlesecond = 0
    frmMain.tmrAntiIdle.Enabled = True
Error:

End Sub

Private Sub Form_Resize()
On Error GoTo Size
rtbChat.Height = Me.Height - 1450
rtbChat.Width = Me.Width - 3495
txtsendbnet.Width = Me.Width - 3495
txtsendbnet.Top = Me.ScaleHeight - 450
lstChannel.Left = Me.Width - 3350
lstChannel.Height = rtbChat.Height - 150
txtChannelInfo.Left = Me.Width - 3350
'frmWinamp.Top = Me.ScaleHeight - 550
'frmWinamp.Left = Me.Width - 1900
imgInvig.Top = Me.ScaleHeight - 450
imgInvig.Left = Me.Width - 3350

Size:

End Sub

Private Sub rtbChat_Change()
 If Len(rtbChat.text) >= 8000 Then
        rtbChat.Visible = False
        rtbChat.SelStart = 0
        removed = InStr(1, rtbChat.text, vbCrLf) + 1
        rtbChat.SelLength = removed
        rtbChat.SelText = vbNullString
        rtbChat.SelStart = 0
        removed = InStr(1, rtbChat.text, vbCrLf) + 1
        rtbChat.SelLength = removed
        rtbChat.SelText = vbNullString
        rtbChat.SelStart = 0
        removed = InStr(1, rtbChat.text, vbCrLf) + 1
        rtbChat.SelLength = removed
        rtbChat.SelText = vbNullString
        rtbChat.SelStart = Len(rtbChat.text)
        rtbChat.Visible = True
    End If
End Sub

Private Sub tmrDC_Timer()
dctime = dctime + 1
connectstatus = False
tmrAntiIdle.Enabled = False
     If dctime = 1 Then
        AddChat D2Green, "Reconnecting in 4 minutes"
    ElseIf dctime = 2 Then
        AddChat D2Green, "Reconnecting in 3 minutes"
    ElseIf dctime = 3 Then
        AddChat D2Green, "Reconnecting in 2 minutes"
    ElseIf dctime = 4 Then
        AddChat D2Green, "Reconnecting in 1 minutes"
    ElseIf dctime = 5 Then
        frmMain.tmrDC.Enabled = False
        AddChat D2Green, "Reconnecting..."
        dctime = 0
        AddChat D2Green, "Battle.net Login Server Connecting to " & BNET.BNLSServer & "..."
        frmMain.wsBnls.Close
        frmMain.wsBnls.Connect BNET.BNLSServer, 9367
        frmMain.Caption = "BNET.cc Bot - [ Connecting to: " & BNET.BNLSServer & " ]"
        txtChannelInfo.Caption = "Connecting"
        txtChannelInfo.ForeColor = D2Green
        antiidlesecond = 0
        frmMain.tmrAntiIdle.Enabled = True
        connectstatus = True
    End If
End Sub

Public Sub tmrUptime_Timer()
    uptimesec = uptimesec + 1
        If uptimesec = 60 Then
            uptimemin = uptimemin + 1
            uptimesec = 0
        If uptimemin = 60 Then
            uptimehour = uptimehour + 1
            uptimemin = 0
        If uptimehour = 24 Then
            uptimedays = uptimedays + 1
            uptimehour = 0
        If uptimedays = 7 Then
            uptimeweek = uptimeweek + 1
            uptimedays = 0
        If uptimeweek = 4 Then
            uptimemonth = uptimemonth + 1
            uptimeweek = 0
        End If
        End If
End If
End If
End If

End Sub
Private Sub ToTray_Click()
TrayToolTip = "BNET.cc Bot [ " & BNET.username & " ]" & vbNewLine & "Version : " & vernum
       Me.WindowState = vbMinimized
        Me.Hide
        With nID
            .cbSize = Len(nID)
            .hWnd = Me.hWnd
            .uId = vbNull
            .uFlags = NIF_ICON Or NIF_TIP Or NIF_Message
            .uCallBackMessage = WM_MOUSEMOVE
            .hIcon = Me.Icon      '
            .szTip = TrayToolTip      'tooltip text
        End With
    Shell_NotifyIcon NIM_ADD, nID
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim Result, Action As Long
    If Me.ScaleMode = vbPixels Then
        Action = X
    Else
        Action = X / Screen.TwipsPerPixelX
    End If
    
Select Case Action

    Case WM_LBUTTONDBLCLK
        Me.WindowState = vbNormal
            Result = SetForegroundWindow(Me.hWnd)
        Me.Show
        Shell_NotifyIcon NIM_DELETE, nID
    
    Case WM_RBUTTONUP
        Result = SetForegroundWindow(Me.hWnd)
    End Select
End Sub

Private Sub txtSendBNET_KeyPress(keyascii As Integer)
            If txtsendbnet.text = "/r " Then
                txtsendbnet.text = "/w " & LastW & Space(1)
                txtsendbnet.SelStart = Len(txtsendbnet.text)
            ElseIf txtsendbnet.text = "/t " Then
                txtsendbnet.text = "/w "
                txtsendbnet.SelStart = Len(txtsendbnet.text)
            ElseIf txtsendbnet.text = "/l " Then
                txtsendbnet.text = "/fmsg "
                txtsendbnet.SelStart = Len(txtsendbnet.text)
            ElseIf txtsendbnet.text = "/em " Then
                txtsendbnet.text = "/me "
                txtsendbnet.SelStart = Len(txtsendbnet.text)
            End If
    If Len(txtsendbnet.text) = 0 Then
    ''
    Else
    If keyascii = "13" Then
        keyascii = "0"
        If Len(txtsendbnet.text) >= 1 Then
                Dim Message As String
                Message = txtsendbnet.text
                DoAddToSendList txtsendbnet.text
                txtsendbnet.text = vbNullString
                Dim channel As String
            If Left$(Message, 1) = "/" Then
                ParseCommand Message, BNET.username, True
                Exit Sub
            End If
        End If
            If Message = "/" Then
            On Error GoTo Err:
                AddChat D2Red, "Cannot send just /. Please specify the command."
            Else
                If wsBnet.State <> Connected Then
                    Send targetuser & Message & postpend, wsBnet
                Else
                    AddChat D2Red, "Battle.net is not connected."
                End If
            End If
Err:
            
        End If
    End If
End Sub


Private Sub Update_Click()
    ShellExecute Me.hWnd, "Open", "http://www.bnet.cc/", 0&, 0&, 0&
End Sub
Private Sub wsBnet_Close()
    mnuConnect.Visible = True
    mnuDisconnect.Visible = False
    AddChat D2Red, "Battle.net Disconnected"
    frmMain.Caption = "BNET.cc Bot - [ Disconnected ]"
    lstChannel.ListItems.Clear
    txtChannelInfo.Caption = "Disconnected"
    txtChannelInfo.ForeColor = D2Red
End Sub

Private Sub wsBnet_Connect()
    mnuConnect.Visible = False
    mnuDisconnect.Visible = True
    AddChat D2Green, "Battle.net Connected!"
    frmMain.Caption = "BNET.cc Bot - [ " & BNET.username & " ]"
    wsBnet.SendData Chr(1)
    Send0x50
    txtChannelInfo.ForeColor = D2LtBlue
End Sub

Private Sub wsBnet_DataArrival(ByVal bytesTotal As Long)
Static strBuffer As String
Dim strTemp As String, lngLen As Long
    wsBnet.GetData strTemp, vbString
    strBuffer = strBuffer & strTemp
    While Len(strBuffer) > 4
        lngLen = Val("&H" & StrToHex(StrReverse(Mid(strBuffer, 3, 2))))
        If Len(strBuffer) < lngLen Then: Exit Sub
        ParseBnet (Left(strBuffer, lngLen))
        strBuffer = Mid(strBuffer, lngLen + 1)
    Wend
End Sub

Private Sub wsBnls_Close()
    AddChat D2Red, "Battle.net Login Server Connection Closed."
    frmMain.Caption = "BNET.cc Bot - [BNLS Connection CLOSED]"
End Sub

Private Sub wsBnls_Connect()
    AddChat D2Green, "Battle.net Login Server Connected!"
    frmMain.Caption = "BNET.cc Bot - [BNLS Connected to " & wsBnls.RemoteHostIP & "]"
    With PBuffer
        .InsertNTString "www.BNET.cc"
        .SendBNLSPacket &HE
    End With
End Sub

Private Sub wsBnls_DataArrival(ByVal bytesTotal As Long)
Dim TempData As String
    wsBnls.GetData TempData, vbString
    ParseBNLS TempData
End Sub

Private Sub ChatBot_OnUser(ByVal username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Long)
Dim thing As New BnetBot
        With frmMain.lstChannel
        If newest = username Then
         'Fuck them
        Else
        If Flags = "2" Then
            .ListItems.Add 1, , username, , thing.GetIconCode(Message, Flags)
            .ListItems(1).ListSubItems.Add , , Ping
            newest = username
        Else
            .ListItems.Add , , username, , thing.GetIconCode(Message, Flags)
            .ListItems(frmMain.lstChannel.ListItems.Count).ListSubItems.Add , , Ping
            newest = username
        End If
        End If
    .Refresh
    End With
    With frmMain.txtChannelInfo
        .Caption = BNET.CurrentChan & " (" & frmMain.lstChannel.ListItems.Count & ")"
    End With
End Sub


Private Sub ChatBot_OnChannel(ByVal ChannelName As String, ByVal Flags As Long)
    With frmMain.lstChannel
        .ListItems.Clear
    End With
    txtChannelInfo.ForeColor = D2LtBlue
    With frmMain.txtChannelInfo
        .Caption = BNET.CurrentChan & " (1)"
    End With
        BanCount = 0
        KickCount = 0
        JoinCount = 0
    With frmMain.lstChannel
        Refresh
    End With
    BNET.CurrentChan = ChannelName
    AddChat D2Orange, "Joining (" & GetChannelType(Flags) & ") " & ChannelName & " w/Flags: " & Flags & "."
End Sub

Private Sub ChatBot_OnEmote(ByVal username As String, ByVal Flags As Long, ByVal Message As String)
    AddChat D2Beige1, "* " & username & Space(1) & Message & " *"
End Sub
Private Sub ChatBot_OnError(ByVal Message As String)

If Message = "That is not a valid command. Type /help or /? for more info." Then
    AddChat D2Red, "Channel is restricted or your mother is a whore."
    AddChat D2Red, "ERROR: " & Message
Else
    AddChat D2Red, "ERROR: " & Message
End If
End Sub

Private Sub ChatBot_OnInfo(ByVal Message As String)

    If InStr(Message, "was kicked out of the channel by") Then
        AddChat D2LtYellow, Message
        KickCount = KickCount + 1
    ElseIf InStr(Message, "was banned by") Then
        'AddChat D2LtYellow, Message
        BanCount = BanCount + 1
    ElseIf InStr(Message, "kicked you") Then
        AddChat D2LtYellow, Message
        Send "/join " & BNET.CurrentChan, frmMain.wsBnet
    Else
        AddChat vbYellow, Message
    End If
End Sub

Private Sub ChatBot_OnFlags(ByVal username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Long)
Dim thing As New BnetBot
'Test
'    For X = 1 To frmMain.lstChannel.ListItems.Count
 '       If frmMain.lstChannel.ListItems.Item(X).text = username Then
  '          With frmMain.lstChannel
   '             .ListItems.Item(X).SmallIcon = thing.GetIconCode(Message, Flags)
    '                If (Flags And &H2) = &H2 Then
     '                   .ListItems.Remove X ' Add 1
      '                  .ListItems.Add 1, , username, , thing.GetIconCode(Message, Flags)
       '                 .ListItems(1).ListSubItems.Add , , Ping
        '            End If
'         '   End With
 '       End If
  '  Next X
End Sub



Private Sub ChatBot_OnJoin(ByVal username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Long)
Dim thing As New BnetBot
    With frmMain.lstChannel
    If Flags = "1" Then
        .ListItems.Add 1, , username, , thing.GetIconCode(Message, Flags)
        newest = username
    Else
        .ListItems.Add , , username, , thing.GetIconCode(Message, Flags)
        newest = username
    End If
    If InStr(username, "#") And Not InStr(username, "#2@") Then
        Else
            AddChat D2Green, username & " has entered the channel. Ping: " & Ping & "ms"
        End If
    With frmMain.txtChannelInfo
        .Caption = BNET.CurrentChan & " (" & frmMain.lstChannel.ListItems.Count & ")"
    End With
.Refresh
End With
End Sub
Private Sub ChatBot_OnLeave(ByVal username As String, ByVal Flags As Long)

On Error Resume Next
    With frmMain.lstChannel
        .ListItems.Remove frmMain.lstChannel.FindItem(username).Index
    End With
    With frmMain.txtChannelInfo
        .Caption = BNET.CurrentChan & " (" & frmMain.lstChannel.ListItems.Count & ")"
    End With
    newest = username & "PART"
            If InStr(username, "#") And Not InStr(username, "#2@") Then
                'fuckoff
            Else
                AddChat D2Red, newest & " (Left channel)"
            End If
End Sub

Private Sub ChatBot_OnTalk(ByVal username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Long)

            If InStr(username, "#") And Not InStr(username, "#2@") Then
                'FuckOff
            Else
                AddChat D2Beige1, ":: " & username & " :: ", D2White, Message
            End If
ParseCommand Message, username 'send commands to parser
End Sub


Private Sub ChatBot_OnUnknown(ByVal UnknownString As String)
    AddChat D2Purple, "UNKNOWN STRING: ", vbRed, UnknownString
End Sub

Private Sub ChatBot_OnWhisperFrom(ByVal username As String, ByVal Flags As Long, ByVal Message As String)

    AddChat D2Beige1, ":: Whisper From: " & username & " :: ", vbGrey, Message
    LastW = username
    'LastCW = "/w " & username & " "
    LastM = Message
    ParseCommand Message, username 'send commands to parser
End Sub

Private Sub ChatBot_OnWhisperTo(ByVal username As String, ByVal Flags As Long, ByVal Message As String, ByVal Ping As Long)

If InStr(Message, "BNET.cc Bot Alpha version:") Then
''
Else
        AddChat D2Beige1, ":: Whisper To: " & username & " :: ", vbGrey, Message

End If
End Sub
Private Sub mnuQC1_Click()
On Error Resume Next
    Send "/join " & lbQC.List(0), frmMain.wsBnet

End Sub
Private Sub wsBnet_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
On Error GoTo Err3:
    AddChat D2Red, "Internet Connection Error: Auto-Reconnecting in 5 mins."
    wsBnet.Close
    wsBnls.Close
    frmMain.tmrDC.Enabled = True
Err3:
    
End Sub


